package com.uchiha.nova.mainService.wrapper;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.uchiha.nova.core.model.entity.MachineInfoEntity;
import com.uchiha.nova.core.model.vo.MachineInfoVO;
import com.uchiha.nova.core.tool.support.BaseEntityWrapper;
import com.uchiha.nova.core.tool.util.SpringUtil;
import com.uchiha.nova.mainService.service.IMachineInfoService;

import java.util.List;
import java.util.stream.Collectors;
/**
 * 机器设备表 包装类,返回视图层所需的字段
 *
 * @author Uchihashiamu
 */
public class MachineInfoWrapper extends BaseEntityWrapper<MachineInfoEntity, MachineInfoVO>  {
  
  IMachineInfoService machineInfoService = SpringUtil.getBean(IMachineInfoService.class);
  
	public static MachineInfoWrapper build() {
		return new MachineInfoWrapper();
 	}

	@Override
	public MachineInfoVO entityVO(MachineInfoEntity machineInfoEntity) {
		MachineInfoVO machineInfoVO = new MachineInfoVO();
		BeanUtil.copyProperties(machineInfoEntity, machineInfoVO);

		return machineInfoVO;
	}
	public List<MachineInfoVO> listVO(List<MachineInfoEntity> list) {
		List<MachineInfoVO> collect = list.stream().map(item -> {
            MachineInfoVO machineInfoVO = new MachineInfoVO();
		    BeanUtil.copyProperties(item, machineInfoVO);			
			return machineInfoVO;
		}).collect(Collectors.toList());
		return collect;
    // return ForestNodeMerger.merge(collect);
	}
  
  	@Override
	public IPage<MachineInfoVO> pageVO(IPage<MachineInfoEntity> pages) {
		IPage<MachineInfoVO> page = pages.convert(item->{
            MachineInfoVO machineInfoVO = new MachineInfoVO();
		    BeanUtil.copyProperties(item, machineInfoVO);			
			return machineInfoVO;
		});
		return page;
	}
}
